package com.clf.manager.controller;

import com.clf.manager.entity.Currm;
import com.clf.manager.entity.Student;
import com.clf.manager.service.StudentService;
import com.clf.manager.util.Result;
import com.clf.manager.util.ScoreDto;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class StudentController {

    @Autowired
    StudentService studentService;


    @RequestMapping("/test")
    public Result test(){
        return Result.fail();
    }

    @RequestMapping("student/scores")
    public Result getSores(@RequestParam("id") String id){
        List<ScoreDto> score = studentService.getScore(id);
        return Result.succ(score);
    }

    @RequestMapping("student/info")
    public Result info(@RequestParam("id") String id){
        return Result.succ(studentService.getById(id));
    }

    @RequestMapping("student/currms")
    public Result getCurrms(@RequestParam("id") String id){
        System.out.println(id);
        List<Currm> getcurrms = studentService.getcurrms(id);
        return Result.succ(getcurrms);
    }

    @GetMapping("/students")
    @RequiresRoles("t")
    public Result students(){
        return Result.succ(studentService.list());
    }

    @RequestMapping("/student/login")
    public Result login(@RequestParam("username") String username,
                        @RequestParam("password") String password){
        return Result.fail();
    }
}
